<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<html>
<head> 
	<title>Videshop POS</title> 
	<link href="../css/style.css" rel="stylesheet" type="text/css">
</head>
<body>
	<f:view>
		<table border="0" cellpadding="0" cellspacing="10">
			<tr>
				<td colspan="2"><h1>Videoshop POS</h1></td>
			</tr>
			<tr>
				<td valign="top">
					<table border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td>
								<!-- User section -->
								<f:subview id="userSection">
									<jsp:include page="user.jsp"/>
								</f:subview>
							</td>
						</tr>
						<tr>
							<td>
								<!-- Menu section -->
								<f:subview id="menuSection">
									<jsp:include page="menu.jsp"/>
								</f:subview>
							</td>
						</tr>
					</table>
				</td>
				<td valign="top" class="mainSection">
					<c:choose>
						<c:when test="${!empty userSection.staff}">
							<h2>Tiitle copies</h2>
						
							<h:form id="titleCopyForm">
								<h:dataTable 	id="titleCopyTable" 
												styleClass="dataTable"
												columnClasses="titleCopyTableIdColumn,titleCopyTableMediumTypeColumn,titleCopyTableStoreNameColumn,titleCopyTableActionColumn"
												value="#{titleSection.selectedTitleCopies}"
												var="copy"
								>
									<h:column headerClass="titleCopyTableIdColumn">
										<f:facet name="header">
											<h:commandLink 	action="#{titleSection.sortTitleCopyByTitleCopyId}">
												<f:verbatim escape="true">Id</f:verbatim>
											</h:commandLink>
										</f:facet>
										<h:outputText value="#{copy.titleCopyId}"/>
									</h:column>
									<h:column headerClass="titleCopyTableMediumTypeColumn">
										<f:facet name="header">
											<h:commandLink 	action="#{titleSection.sortTitleCopyByMediumType}">
												<f:verbatim escape="true">Format</f:verbatim>
											</h:commandLink>
										</f:facet>
										<h:graphicImage url="#{copy.medium.mediumType.iconUrl}" height="60px"/>
									</h:column>
									<h:column headerClass="titleCopyTableStoreNameColumn">
										<f:facet name="header">
											<h:commandLink 	action="#{titleSection.sortTitleCopyByStoreName}">
												<f:verbatim escape="true">Store</f:verbatim>
											</h:commandLink>
										</f:facet>
										<h:outputText value="#{copy.store.storeName}"/>
									</h:column>
									<h:column headerClass="titleCopyTableActionColumn">
										<f:facet name="header">
											<f:verbatim escape="true">Action</f:verbatim>
										</f:facet>
										<h:commandLink styleClass="button" action="#{titleSection.deleteTitleCopy}">
											<f:verbatim escape="true">Delete</f:verbatim>
										</h:commandLink>
									</h:column>
								</h:dataTable>
								<h:panelGrid columns="4">
									<h:inputText styleClass="text100" value="#{titleSection.newTitleCopyId}"/>
									<h:selectOneListbox	styleClass="select100" size="1" value="#{titleSection.newTitleCopyMediumType}">
										<f:selectItems value="#{titleSection.newTitleCopyAvailableMediumType}"/>
									</h:selectOneListbox>
									<h:selectOneListbox	styleClass="select200" size="1" value="#{titleSection.newTitleCopyStoreId}">
										<f:selectItems value="#{titleSection.newTitleCopyAvailableStores}"/>
									</h:selectOneListbox>
									<h:commandLink styleClass="button" action="#{titleSection.addTitleCopy}">
										<f:verbatim escape="true">Add</f:verbatim>
									</h:commandLink>
								</h:panelGrid>
							</h:form>
							<h:form>
								<h:commandLink styleClass="moreButton" action="browse" value="Back"/>
							</h:form>
						</c:when>
						<c:otherwise>
							Please login first
						</c:otherwise>
					</c:choose>
				</td>
			</tr>
		</table>
	</f:view>
</html>